package app.server.project.core.tcp;

import app.server.project.core.tcp.model.TcpRespModel;
import cn.hutool.json.JSONUtil;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 编码器
 */
@Slf4j
public class JsonEncoder extends MessageToByteEncoder<TcpRespModel> {

    @Override
    protected void encode(ChannelHandlerContext ctx, TcpRespModel data, ByteBuf buf)
            throws Exception {
        buf.writeBytes(data.toByte());
    }
}
